home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / modelers / geomview / source.lha / Geomview / include / mgP.h < prev    next >
C/C++ Source or Header  |  1993-08-30  |  5KB  |  145 lines

  1. /* Copyright (c) 1992 The Geometry Center; University of Minnesota
  2.    1300 South Second Street;  Minneapolis, MN  55454, USA;
  3.    
  4. This file is part of geomview/OOGL. geomview/OOGL is free software;
  5. you can redistribute it and/or modify it only under the terms given in
  6. the file COPYING, which you should have received along with this file.
  7. This and other related software may be obtained via anonymous ftp from
  8. geom.umn.edu; email: software@geom.umn.edu. */
  9.  
  10. /* Authors: Charlie Gunn, Stuart Levy, Tamara Munzner, Mark Phillips */
  11.  
  12. #ifndef _MG_PDEFS_
  13. #define _MG_PDEFS_
  14.  
  15. /*
  16.  * Private, but machine-independent, declarations for mg library.
  17.  */
  18. #include "mg.h"
  19.  
  20. #define    MGCONTEXTMAGIC    OOGLMagic('m', 'c'<<8 | 1)
  21.  
  22. /*
  23.  * Appearance portion of state.
  24.  * We have a global stack of these which represent the user-specified values,
  25.  * with a stack push at every mgpushappearance().
  26.  */
  27. struct mgastk {
  28.     struct mgastk    *next;    /* stack link */
  29.     short        changed;
  30.     short        ap_seq, mat_seq, light_seq;
  31.     Appearance    ap;    /* Shallow copy of appearance -- don't delete */
  32.     Material    mat;    /* Ditto, Material */
  33.     LmLighting    lighting;/* Ditto, Lighting */
  34.  
  35.     int        useshader; /* Flag: use shader function? (shader!=NULL
  36.                     && appearance requires shading */
  37.     mgshadefunc    shader; /* Software shading function, or NULL if none */
  38.     void        *shaderdata; /* Data which shader might use */
  39. };
  40.  
  41. /*
  42.  * Transform stack, pushed by mgpushtransform().
  43.  */
  44. struct mgxstk {
  45.     struct mgxstk    *next;    /* stack link */
  46.     Transform    T;    /* Current object->world xform */
  47.     short        xfm_seq;
  48.     short        hasinv;    /* Flag: Tinv is valid */
  49.     Transform    Tinv;
  50. };
  51.  
  52. struct mgcontext {
  53.     REFERENCEFIELDS
  54.     struct mgfuncs    *devfuncs; /* Pointers to devices */
  55.     short    devno;        /* Device index -- MGD_GL, MGD_X11, ... */
  56.  
  57.     short    changed;    /* flags: Must update device state because...*/
  58. #define      MC_WIN    0x01    /*  window changed (reshaped, &c) */
  59. #define      MC_CAM    0x02    /*  Camera changed */
  60. #define      MC_AP        0x04    /*  Appearance changed */
  61. #define      MC_MAT    0x08    /*  Material changed */
  62. #define      MC_LIGHT    0x10    /*  Lighting changed */
  63. #define   MC_TRANS    0x20    /*  Transformation changed */
  64. #define      MC_OPT    0x40    /*  Options changed */
  65.  
  66.     WnWindow    *win;    /* Window */
  67.     Camera        *cam;    /* Camera */
  68.     mgcontext    *parent; /* Parent mg window, if any */
  69.     mgcontext    *next;    /* Link in list of all mg contexts */
  70.     struct mgastk    *astk;    /* Top of appearance stack */
  71.     struct mgxstk    *xstk;    /* Top of transform stack */
  72.     int        shown;    /* Is window 'visible'? */
  73.     ColorA        background; /* Background color */
  74.  
  75.     int        opts;    /* MG_SETOPTIONS flag mask */
  76.  
  77.     Transform    W2C;    /* World->camera transform */
  78.     Transform    C2W;    /* Camera->world transform */
  79.  
  80.     Transform    T4;    /* 4D->3D transform */
  81.     int        T4_seq;    /* sequence number for T4 */
  82.  
  83.     float        zfnudge; /* fraction of Z-range by which lines are
  84.                   * nudged closer than surfaces.
  85.                   */
  86.     int        space;    /* space in which objects being drawn
  87.                  * live; should be TM_EUCLIDEAN,
  88.                  * TM_HYPERBOLIC, or TM_SPHERICAL
  89.                  */
  90.  
  91.  
  92.     Transform    W2S, S2W; /* world-to-screen, screen-to-world xfms */
  93.  
  94.     int        has;    /* Flag bits, set when cached values valid */
  95. #define HAS_CPOS   0x1
  96. #define    HAS_S2O       0x2
  97. #define HAS_POINT  0x4
  98.                 /* Cached values, computed when needed: */
  99.     Point3        cpos;      /* Location of camera in object coordinates */
  100.     Transform    O2S, S2O; /* object-to-screen, screen-to-object xfms */
  101.     vvec        point;    /* outline for fat points */
  102.  
  103.     void        *NDinfo; /* Opaque pointer to caller-defined ND closure */
  104.     mgmapfunc    NDmap;    /* NDmap(NDinfo, HPtN *, HPt3 *, ColorA *) */
  105. };
  106.  
  107. /*
  108.  * Pointer to the current mg context.
  109.  */
  110. extern struct mgcontext *_mgc;
  111.  
  112. /*
  113.  * List of all extant mg contexts.
  114.  */
  115. extern struct mgcontext *_mgclist;
  116.  
  117. /*
  118.  * Declarations of common mg routines, accessible to other mg packages
  119.  * (but not intended to be public):
  120.  */
  121.  
  122. extern void mg_identity(void);
  123. extern void mg_transform(Transform T);
  124. extern void mg_settransform(Transform T);
  125. extern void mg_gettransform(Transform T);
  126. extern void mg_quads(int nquads, HPoint3 *v, Point3 *n, ColorA *c);
  127. extern void mg_bezier(int du, int dv, int dimn, float *ctrlpts, float *txmapst,
  128.   ColorA *c);
  129. extern void mg_findcam();
  130. extern void mg_findS2O();
  131. extern void mg_findO2S();
  132. extern void mg_makepoint();
  133.  
  134. extern int mg_pushtransform(void),  mg_poptransform(void);
  135. extern int mg_pushappearance(void), mg_popappearance(void);
  136. extern void mg_reshapeviewport(void);
  137. extern Appearance *mg_getappearance(void);
  138. extern Appearance *mg_setappearance(Appearance *ap, int mergeflag);
  139.  
  140. extern mgcontext *mg_newcontext(struct mgcontext *);
  141. extern int mg_appearancebits( Appearance *ap, int merge, int *valid, int *flag );
  142.  
  143.  
  144. #endif /*_MG_PDEFS_*/
  145.